#! /usr/bin/env python
# encoding: utf-8

import ibexutils
import os, sys
from waflib import Logs

######################
###### options #######
######################
def options (opt):
	pass # no options for this plugin

######################
##### configure ######
######################
def configure (conf):
	if conf.env["INTERVAL_LIB"]:
		conf.fatal ("Trying to configure a second library for interval arithmetic")
	conf.env["INTERVAL_LIB"] = "DIRECT"

	Logs.warn ("Using interval library direct may not give exact results")

	conf.check_cxx (cxxflags = "-frounding-math", use = [ "IBEX", "ITV_LIB" ],
			uselib_store = "ITV_LIB")
	conf.check_cxx (cxxflags = "-ffloat-store", use = [ "IBEX", "ITV_LIB" ],
			uselib_store = "ITV_LIB")


	# Looking for filib headers and library.
	# We also test if we need to add sse2 or sse3 flags.
	D = {"mandatory": False, "errmsg": "no", "use": [ "IBEX", "ITV_LIB" ], "uselib_store": "ITV_LIB"}
	D["cxxflags"] = "-msse3"
	ret = conf.check_cxx (**D)
	if not ret:
		D["cxxflags"] = "-msse2"
		conf.check_cxx (**D)
